// eslint-disable-next-line no-unused-vars

/**
 * 开发环境配置
 * 微信开发者工具 访问 ：  http://localhost:8080/ch/page/weapp/index.html
 * @type {string}
 */

const appId = 'wx79adb4fb5690f3cf'
const aliAppId = '2021003139694195'
const aliSubName = '科航新能源'
const wxSubName = '科航物联设备展示'
const api = 'http://test.kedouyun.top/ch'
const host = 'http://test.kedouyun.top/ch/page/weapp/index.html' // 授权所需域名
const testOpenId = ''
// const api = 'http://localhost:8081/ch'
// const host = 'http://localhost:8080/ch/page/weapp/index.html' // 授权所需域名
// const testOpenId = 'oNs3X6VwSJ2ixDhUbcamei3XF1jw'

// 获取地址栏参数
const getQueryString = (name) => {
  // eslint-disable-next-line no-sparse-arrays
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null
}
const isWeApp = () => {
  // eslint-disable-next-line eqeqeq
  const ua = window.navigator.userAgent.toLowerCase()
  console.log(ua)
  return window.navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
}
const isNull = (val) => {
  return val === '' || val === null || val === undefined || val === 'undefined'
}
const DateMonth = (date) => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  let nextYear = date.getFullYear()
  let nextMonth = date.getMonth() + 2
  if (nextMonth > 12) {
    nextMonth = 1
    nextYear = nextYear + 1
  }
  return year + '-' + month + '-1,' + nextYear + '-' + nextMonth + '-1'
}

// const testPhoneNumber = () =>  {}
export default {
  isWeApp,
  getQueryString,
  isNull,
  api,
  host,
  appId,
  aliAppId,
  wxSubName,
  aliSubName,
  DateMonth,
  testOpenId
}
